<?php

namespace common\models;

use backend\logic\RoleLogic;
use Yii;
use yii\db\ActiveRecord;

/**
 * This is the model class for table "{{%auth_role}}".
 *
 * @property integer $id
 * @property string $name
 * @property string $des
 * @property string $create_date
 * @property string $update_date
 * @property integer $status
 * @property string $rule
 */
class AuthRoleModel extends ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%auth_role}}';
    }

    public function scenarios()
    {
        $scenarios = parent::scenarios();
//      $scenarios[self::SCENARIO_CREATE] = [ 'name', 'create_date', 'des'];
//      $scenarios[self::SCENARIO_UPDATE] = [ 'name', 'update_user', 'des', 'update_date', 'rule'];
        return $scenarios;

    }


    public function rules()
    {
        return [
            ['name', 'required', 'message' => '名称必须'],
            [['create_date', 'update_date'], 'safe'],
            ['update_date', 'default', 'value' => self::getDate()],
            ['create_date', 'default', 'value' => self::getDate()],
            [['name'], 'string', 'max' => 50],
            [['des'], 'string', 'max' => 400],
            ['rule', 'string',]
        ];

    }

    public function attributeLabels()
    {
        return [
            'id' => '主键',
            'code' => '角色编号',
            'name' => '角色名称',
            'des' => '角色描述',
            'create_user' => '创建人',
            'create_date' => '创建时间',
            'update_user' => '更新人',
            'update_date' => '更新时间',
            'rule' => '权限',
            'status' => '状态',
        ];
    }
    public static function getDate()
    {
        return date('Y-m-d H:i:s');
    }
}
